package org.example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class TestMaven {
    public static void main(String[] args)throws Exception {
        System.out.println("这是一个maven项目");
        System.out.println("查询数据库，获取所有用户信息：");
        Class.forName("com.mysql.jdbc.Driver");
        Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test_maven",
                "root","");
        PreparedStatement pstmt = conn.prepareStatement("select * from user");
        ResultSet rs = pstmt.executeQuery();
        while(rs.next()){
            System.out.print(rs.getInt("id")+"\t");
            System.out.print(rs.getString("username")+"\t");
            System.out.print(rs.getInt("age")+"\t");
            System.out.print(rs.getTimestamp("birth")+"\t");
            System.out.println();
        }
        rs.close();
        conn.close();

    }
}
